#include <stdio.h>
//传递函数指针
typedef int (*FunType)(int ,int);
int add(int a,int b){
    return a+b;
}
int re(int a,int b){
    return a-b;
}
int computer(FunType fun,int a,int b){
    return fun(a,b);
}
//返回函数指针
FunType op (char c){
    switch (c){
        case '+':
            return add;
        case '-':
            return re;
    }
}
int computer2(char c,int a,int b){
    FunType fun = op(c);
    return fun(a,b);
}


int main(){
    printf("Hello, World!\n");
    printf("传递函数指针 = %d\n",computer(add,1,2));
    printf("传递函数指针 = %d\n",computer(re,1,2));
    printf("返回函数指针 = %d\n",computer2('+',6,2));
    printf("返回函数指针 = %d\n",computer2('-',0,3));
    return 0;
}